import { find } from "lodash";
import styles from "./index.module.less";
import cs from 'classnames';

export const getTableColumns = ({ params, msgTypeList }: any) => [
	{
		title: "时间",
		dataIndex: "createTime",
		width: 140,
		ellipsis: true
	},
	{
		title: "消息类型",
		dataIndex: "type",
		width: 140,
		ellipsis: true,
		render: (_: any, record: any) => {
			const result = find(msgTypeList?.data || [], (item: any) => item.value === `${record.type}`)
			return (
				<span className={cs(
					styles.alertTab, 
					record.type === 1 && styles.success,
					record.type === 2 && styles.warning,
					record.type === 3 && styles.danger,
				)}>
					{result?.label}
				</span>
			)
		}
	},
	{
		title: "任务名称",
		dataIndex: "jobName",
		width: 140,
		ellipsis: true
	},
	{
		title: "任务编号",
		dataIndex: "jobId",
		width: 140,
		ellipsis: true
	},
	{
		title: "接驳点名称",
		dataIndex: "siteId",
		width: 100,
		ellipsis: true,
	},
	{
		title: "车辆编号",
		dataIndex: "vehId",
		width: 100,
		ellipsis: true,
	},
	{
		title: "消息内容",
		dataIndex: "remark",
		width: 140,
		ellipsis: true
	},
];

export const USER_STATUS = [
	{ label: '在线', value: 1 },
	{ label: '离线', value: 2 }
]

export const getSearchColumns = ({msgTypeList}: any) => [
	{
		type: "select",
		placeholder: "消息类型",
		name: "type",
		options: msgTypeList?.data
	},
	{
		type: "input",
		placeholder: "任务名称",
		name: "jobName"
	},
	{
		type: "select",
		placeholder: "任务编号",
		name: "jobId"
	},
	{
		type: "input",
		placeholder: "车辆编号",
		name: "vehId"
	},
]